package com.szxy.common.redis.controller;

import com.szxy.common.redis.service.RedisCartService;
import com.szxy.utils.CartItem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Auther:zwer
 * @Date:2019/9/25 15:30
 * @Description:com.szxy.common.redis.controller
 * @Version:1.0
 **/
@RestController
@RequestMapping("/redis/cart")
public class RedisCartController {

    @Autowired
    private RedisCartService redisCartService;

    @PostMapping("/insertToCart")
    public void insertToCart(@RequestBody  Map<String, Object> map){
        this.redisCartService.insertToCart(map);
    }

    @GetMapping("/selectCartByUserId")
    public Map<String, CartItem> selectCartByUserId(@RequestParam("userId") String userId){
        return this.redisCartService.selectCartByUserId(userId);
    }

}
